package com.xwj.controller;

import com.xwj.dto.CommonResult;
import com.xwj.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author xwj
 * @date 2020/11/13
 */
@RestController
public class StorageController {
    @Autowired
    private StorageService storageService;

    /**
     * 扣减库存
     * @param productId
     * @param count
     * @return
     */
    @RequestMapping("/storage/decrease")
    public CommonResult decrease(Long productId, Integer count) {
        if(storageService.decrease(productId, count)) {
            return new CommonResult(200, "扣减库存成功");
        }
        return CommonResult.error();
    }
}
